Linux非root用户安装及配置Nginx[吊打某度95%以上的教程]

您所在的位置:网站首页 linux nginx rpm安装 Linux非root用户安装及配置Nginx[吊打某度95%以上的教程]

Linux非root用户安装及配置Nginx[吊打某度95%以上的教程]

2023-03-27 06:04| 来源: 网络整理| 查看: 265

文章时间:2019年12月17日 11:08:08 解决问题:Linux系统非root用户安装及配置Nginx 基于系统:RedHat CentOS

说明:该文章还是用到了2次root权限,其中有一次root权限是没有必要用的,我会在文章中进行说明。该文章不吹不闹,吊打某度上95%以上的教程,我测试了前4页面的文章,某度教程只有2篇可用的文章,我会加到底部的参考文献里面。一、安装前置依赖gcc编译器(第一次需要root权限)

这里我没研究非root用户安装(因为太麻烦了),后面我会单独出一篇文章,讲解非root用户安装gcc编译器。

直接使用su - 切换到root用户下面,使用yum安装gcc。

yum install -y gcc-c++下载及解压pcrewget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz tar zxvf pcre-8.43.tar.gz

这里使用wget命令下载的,如果你也像我一样,是个纯内网的,那么,请到文章底部,直接下载我下载好的包吧。

下载及解压zlibwget http://zlib.net/zlib-1.2.11.tar.gz tar zxvf zlib-1.2.11.tar.gz下载及解压opensslwget https://www.openssl.org/source/openssl-1.0.2s.tar.gz tar zxvf openssl-1.0.2s.tar.gz下载及解压nginxwget http://nginx.org/download/nginx-1.16.1.tar.gz tar zxvf nginx-1.16.1.tar.gz二、开始安装检查配置文件cd nginx-1.16.1./configure \ --prefix=../nginx \ --with-pcre=../pcre-8.43 \ --with-zlib=../zlib-1.2.11 \ --with-openssl=../openssl-1.0.2t \ --user=root \ --group=root \ --with-file-aio \ --with-http_v2_module \ --with-http_ssl_module \ --with-http_realip_module \ --with-http_sub_module \ --with-http_gzip_static_module \ --with-http_stub_status_module

说明:如果你能看懂上面的,你就看懂,如果看不懂,你就复制粘贴运行。 --prefix=../nginx \ 这里可以写成你的绝对路径。

执行安装make install三、启动及配置增加权限(第二次用到root权限)

非root用户运行nginx不能监听1024以下的端口号。所以我们需要如下的操作:

需要root用户cd到sbin目录中设权限

chown root:root nginx chmod 755 nginx chmod u+s nginx启动/nginx/sbin/nginx

输入上面的命令即可正常启动nginx。

# 检查配置文件 /nginx/sbin/nginx -t # 重启nginx /nginx/sbin/nginx -s reload四、参考资料CentOS一键编译安装nginx,带http2/brotli/zlib/pcre/ssl,非root监听80端口:https://blog.csdn.net/hursing/article/details/93860565zzw原创_非root用户下安装nginx:https://www.cnblogs.com/zzw-zyba/p/8820160.html五、离线文件包

链接: https://pan.baidu.com/s/1llum2N419M1ed9MkUVRXiA 提取码: zhia



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3